package com.bloom.opensourceframework.eventbus.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.bloom.opensourceframework.R;
import com.bloom.opensourceframework.activity.BaseActivity;
import com.bloom.opensourceframework.eventbus.entity.MessageEvent;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by bloom on 2018/5/7.
 * <p>
 * EventBus frame use
 */

public class EventBusExampleActivity extends BaseActivity {

    private final String TAG = this.getClass().getSimpleName();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_eventbus);
        setTitle("Event Bus");
        findViewById(R.id.bt_finish).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EventBus.getDefault().post(new MessageEvent(TAG + ": finish"));
                finish();
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
//        EventBus.getDefault().register(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
//        EventBus.getDefault().unregister(this);
    }

}
